const {readdirSync} = require('fs')
const { getProperty,assert } = require('../../lib/tools')
const { readYaml } = require('../../lib/files')
const { join } = require('path')
// 生成前端vue页面
module.exports = function({config:{globeConfig:{globe}},writeOutTheArea}){
    // 根据配置目录的配置文件进行循环迭代
    const dirPath = getProperty(globe,g=>g.dist.front.configPath,undefined)
    assert(dirPath,"前端配置路径不能为空")
    const files = getProperty(globe,g=>readdirSync(g.dist.front.configPath),undefined)
    if(!files){
        console.error("前端配置文件目录错误!")
    }
    
    
    const checkType = c=> c.type && c.type==='view'
    files.forEach(f=>{
        // 读入前端页面的配置
        const filePath = join(dirPath,f)

        const content = getProperty(filePath,f=> readYaml(f),undefined)

        if(content && checkType(content)){
            content.format = 'vue'
            writeOutTheArea.push(content)
        }

    })

    // doGenerate(files,dirPath,formatOption,c=> c.type && c.type==='view');
    
       
}


